package homework4.test;

/**
 * @author fengq
 */
public class JoinThread extends Thread{
    public JoinThread(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i=0;i<5;i++){
            System.out.println(Thread.currentThread().getName()+""+i);
        }
    }

    public static void main(String[] args) {
        for (int i=0;i<10;i++){
            if (i==5){
                JoinThread tempjt = new JoinThread("MyThread");

                try {
                    tempjt.start();
                    tempjt.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getName()+""+i);
        }
    }
}
